<% layout('/layouts/default.html', {title: '数据管理', libs:
['validate','fileupload','ueditor','dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text(ztGoodsOrder.isNewRecord ?
				'新增订单' : '查看订单【买】')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool"
					data-widget="collapse">
					<i class="fa fa-minus"></i>
				</button>
			</div>
		</div>

		<#form:form id="inputForm" model="${ztGoodsOrder}"
		action="${ctx}/ztGoodsOrder/save" method="post"
		class="form-horizontal">
		<div class="box-body">
			<div class="form-unit">${text('订单信息')}</div>
			<#form:hidden path="id"/>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('物流名称')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">											
							<#form:select path="logisticsCode"
							items="${logisticsList}" itemLabel="logisticsName" itemValue="logisticsCode"
							blankOption="true" class="form-control required"/>
						</div>

					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required hide">*</span> ${text('物流单号')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="logistics"
							maxlength="50" class="form-control required "/>
							
						<input id="retrieval" onclick="openWin('${ctx}/ztWl/list?logistics=${ztGoodsOrder.logistics}&logisticsCode=${ztGoodsOrder.logisticsCode}', 900, 600)"
							class="btn btn-primary" type="button" style="background:#00B2EE;margin-top: 4px;" value="查看物流信息" />
						</div>
					</div>
				</div>
			</div>
			
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('订单号')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztGoodsOrder.order}</div>
					</div>
				</div>
			</div>
			
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required hide">*</span> ${text('微信名')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztGoodsOrder.ztAdmin.name}</div>
					</div>
				</div>
				
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('收货地址')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztGoodsOrder.addr}</div>
					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('收货人')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztGoodsOrder.name}</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required hide">*</span> ${text('电话号码')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztGoodsOrder.phone}</div>
					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('订单状态')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztGoodsOrder.orderstatus}</div>

					</div>
				</div>

				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('数量')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztGoodsOrder.numCount}</div>

					</div>
				</div>

			</div>
			
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('单价')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztGoodsOrder.goodsPrice}</div>

					</div>
				</div>

				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('商品合计总价')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztGoodsOrder.totalPrice}</div>

					</div>
				</div>

			</div>
			
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('余额')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztGoodsOrder.balance}</div>

					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('颜色')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztGoodsOrder.colorName}</div>

					</div>
				</div>
			
			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('商品名称')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							
								<a href="${ctx}/ztGoods/queForm?id=${ztGoodsOrder.ztGoods.id}&color=${ztGoodsOrder.colorid}" class="btnList" title="${ztGoodsOrder.ztGoods.title}" data-click-binded="true">
								${ztGoodsOrder.ztGoods.title} </a>
						</div>

					</div>
				</div>

				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('规格')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztGoodsOrder.guigeName}</div>

					</div>
				</div>
			</div>
			
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required hide">*</span> ${text('下单时间')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							${ztGoodsOrder.orderTime,dateFormat="yyyy-MM-dd HH:mm:ss"}</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required hide">*</span> ${text('付款时间')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							${ztGoodsOrder.payTime,dateFormat="yyyy-MM-dd HH:mm:ss"}</div>
					</div>
				</div>
			</div>
			
			
			<% 								
				if (ztGoodsOrder.issueTime != null){ 
			%>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required hide">*</span> ${text('发货时间')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							${ztGoodsOrder.issueTime,dateFormat="yyyy-MM-dd HH:mm:ss"}</div>
					</div>
				</div>
			</div>
			<% } %>
			

			<% if(ztGoodsOrder.ztQuanselfList.~size>0){ %>
				<h4 class="form-unit">${text('卡券列表')}</h4>
			<div class="ml10 mr10">
				<table id="quanDataGrid"></table>
			</div>
			<%}%>

		<div class="box-footer">
			<div class="row">
				<div class="col-sm-offset-2 col-sm-10">
					<% if (hasPermi('ztGoodsOrder:ztGoodsOrderData:edit')){ %>
				
				
					<% 								
					if (ztGoodsOrder.orderstatus=='待发货'){ 
					%>					
					<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit">
						<i class="fa fa-check"></i> ${text('确认发货')}
					</button>
					<% } %>
					
					<% 								
					if (ztGoodsOrder.orderstatus=='已发货'){ 
					%>					
					<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit">
						<i class="fa fa-check"></i> ${text('保存')}
					</button>
					<% } %>
					
					&nbsp; <% } %>
					<button type="button" class="btn btn-sm btn-default" id="btnCancel"
						onclick="js.closeCurrentTabPage()">
						<i class="fa fa-reply-all"></i> ${text('关 闭')}
					</button>
				</div>
			</div>
		</div>
		</#form:form>
	</div>
</div>
<% } %>

<script>

//初始化测试数据子表DataGrid对象
$("#quanDataGrid").dataGrid({

	data: ${toJson(ztGoodsOrder.ztQuanselfList)},
	datatype: "local", // 设置本地数据
	autoGridHeight: function(){return 'auto'}, // 设置自动高度
	
	// 设置数据表格列
	columnModel: [

		{header:'卡券名', name:'name', width:150,align:"center"},
		{header:'${text('图片')}', name:'imgs',  width:150, align:"center",formatter: function(val, obj, row, act){
			return '<img style="width:40px;height:40px;" src="'+val+'"></img>';
		}},
		{header:'卡券面值', name:'price',align:"center", width:100},
		{header:'${text('状态')}', name:'type', width:100, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('zt_quan_type')}, val, '${text('现金券')}', true);
		}}
		
	],
	
	// 编辑表格参数
	editGrid: false,				// 是否是编辑表格
	
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});

	//初始化测试数据子表DataGrid对象
	$("#testDataChildDataGrid")
			.dataGrid(
					{

						data : ${toJson(ztGoodsOrder.ztGoodsList)},
						datatype : "local", // 设置本地数据
						autoGridHeight : function() {
							return 'auto'
						}, // 设置自动高度

						// 设置数据表格列
						columnModel : [
								{
									header : '${text('商品名')}',
									name : 'title',
									width : 200,
									align : "center",
									sortable : false,
									fixed : true,
									formatter : function(val, obj, row, act) {
										var actions = [];
										actions
												.push('<a href="${ctx}/ztGoods/queForm?id='
														+ row.id
														+ '&color='
														+ row.code
														+ '" class="btnList" title="'
														+ val
														+ '" >'
														+ val
														+ '</a>');
										return actions.join('');
									},
									editoptions : {
										defaultValue : 'new'
									}
								},

								{
									header : '颜色',
									name : 'code',
									width : 100,
									align : "center"
								},

								{
									header : '数量',
									name : 'count',
									width : 100,
									align : "center"
								}, {
									header : '单价',
									name : 'price',
									align : "center",
									width : 100
								}, {
									header : '总价',
									name : 'goodstemp',
									align : "center",
									width : 100
								}

						],

						// 编辑表格参数
						editGrid : false, // 是否是编辑表格

						// 加载成功后执行事件
						ajaxSuccess : function(data) {

						}
					});

	//初始化测试数据子表DataGrid对象
	$("#quanDataGrid")
			.dataGrid(
					{

						data : ${toJson(ztGoodsOrder.ztQuanselfList)},
						datatype : "local", // 设置本地数据
						autoGridHeight : function() {
							return 'auto'
						}, // 设置自动高度

						// 设置数据表格列
						columnModel : [

								{
									header : '卡券名',
									name : 'name',
									width : 150,
									align : "center"
								},
								{
									header : '${text('图片')}',
									name : 'imgs',
									width : 150,
									align : "center",
									formatter : function(val, obj, row, act) {
										return '<img style="width:40px;height:40px;" src="'+val+'"></img>';
									}
								},
								{
									header : '卡券面值',
									name : 'price',
									align : "center",
									width : 100
								},
								{
									header : '${text('状态')}',
									name : 'type',
									width : 100,
									align : "center",
									formatter : function(val, obj, row, act) {
										return js
												.getDictLabel(
														${@DictUtils.getDictListJson('zt_quan_type')},
														val, '${text('现金券')}',
														true);
									}
								}

						],

						// 编辑表格参数
						editGrid : false, // 是否是编辑表格

						// 加载成功后执行事件
						ajaxSuccess : function(data) {

						}
					});
</script>

<script>
function openWin(u, w, h) { 
    var l = (screen.width - w) / 2; 
    var t = (screen.height - h) / 2; 
    var s = 'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l; 
    s += ', toolbar=no, scrollbars=no, menubar=no, location=no, resizable=no'; 
    open(u, 'oWin', s); 
} 


	$("#inputForm").validate({
		submitHandler : function(form) {
			js.ajaxSubmitForm($(form), function(data) {
				js.showMessage(data.message);
				if (data.result == Global.TRUE) {
					js.closeCurrentTabPage(function(contentWindow) {
						contentWindow.page();
					});
				}
			}, "json");
		}
	});
</script>